let Util = {}

Util.title = function (title) {
  title = title || '日志查询系统';
  window.document.title = title;
};


// 存储session 或者获取session 一个参数表示获取，两个参数表示存储
Util.session = (key, value) => {
  if (typeof value === 'number' || typeof value === 'boolean') {
    sessionStorage.setItem(key, value)
    return
  }
  if (value) {
    if (typeof value == 'object') {
      value = JSON.stringify(value)
    }
    sessionStorage.setItem(key, value)
    return
  }

  let session = sessionStorage.getItem(key)
  if (session) {
    try {
      session = JSON.parse(session)
    } catch (e) {
      session = session
    }
  } else {
    session = null
  }
  return session
}

export default Util;


